package priv.wangy.micro.common.utils;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.Locale;

/**
 * @author wangy
 * @since 2023-10-26
 */
public class TokenUtil {

    /**
     * 生成token
     *
     * @param salt 盐值
     * @return java.lang.String
     * @author wangy
     * @since 2023-10-26
     */
    public static String getToken(String salt) {
        long time = (new Date()).getTime();
        return DigestUtils.md5DigestAsHex((salt + time).getBytes(StandardCharsets.UTF_8)).toUpperCase(Locale.ROOT);
    }
}
